﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using z_tool.config;

namespace z_tool
{
    public partial class setting_java : Form
    {
        public setting_java()
        {
            InitializeComponent();
        }

        private void setting_java_Load(object sender, EventArgs e)
        {
            var itemx = baseconfig.generate_type.Where(s => s.value == "1").FirstOrDefault();
            textBox1.Text = itemx.setting["package"].ToString();
            textBox2.Text = itemx.setting["module"].ToString();
            textBox3.Text = itemx.setting["version_key"].ToString();
            textBox4.Text = itemx.setting["tablePrefix"].ToString();
            textBox5.Text = itemx.setting["description"].ToString();
            if(itemx.setting.ContainsKey("parent_key"))
                textBox6.Text = itemx.setting["parent_key"].ToString();
            if (itemx.setting.ContainsKey("parent_name"))
                textBox7.Text = itemx.setting["parent_name"].ToString();
            if (itemx.setting.ContainsKey("dynamic_datasource"))
                textBox8.Text = itemx.setting["dynamic_datasource"].ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var itemx = baseconfig.generate_type.Where(s => s.value == "1").FirstOrDefault();
            if (!string.IsNullOrEmpty(textBox1.Text))
            {
                itemx.setting["package"] = textBox1.Text;
            }
            if (!string.IsNullOrEmpty(textBox2.Text))
            {
                itemx.setting["module"] = textBox2.Text;
            }
            if (!string.IsNullOrEmpty(textBox3.Text))
            {
                itemx.setting["version_key"] = textBox3.Text;
            }
            //if (!string.IsNullOrEmpty(textBox4.Text))
            //{
                itemx.setting["tablePrefix"] = textBox4.Text;
            //}
            if (!string.IsNullOrEmpty(textBox5.Text))
            {
                itemx.setting["description"] = textBox5.Text;
            }
            if (!string.IsNullOrEmpty(textBox6.Text))
            {
                itemx.setting["parent_key"] = textBox6.Text;
            }
            if (!string.IsNullOrEmpty(textBox7.Text))
            {
                itemx.setting["parent_name"] = textBox7.Text;
            }
            if (!string.IsNullOrEmpty(textBox8.Text))
            {
                itemx.setting["dynamic_datasource"] = textBox8.Text;
            }
            this.Close();
        }
    }
}
